﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using KpiConfigProject.Manager;

namespace KpiConfigProject.ChildForm
{
    public partial class DimensionConfigForm : Form
    {
        public DimensionConfigForm()
        {
            InitializeComponent();
        }

        private void DimensionConfigForm_Load(object sender, EventArgs e)
        {
            InitAllData();
        }

        private void tsb_Refresh_Click(object sender, EventArgs e)
        {
            InitAllData();
        }

        private void InitAllData()
        {
            IManager dimManager = new DimensionManager();
            DataTable table = dimManager.GetList();
            if (table != null)
                dgve_Dimension.DataSource = table.DefaultView;

            dimManager = new DimensionDetailManager();
            table = dimManager.GetList();
            if (table != null)
                dgve_DimensionDetail.DataSource = table.DefaultView;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tsb_Add_Click(object sender, EventArgs e)
        {
            if (tabControl1.SelectedIndex == 0)
            {
                dgve_Dimension.AddNewRow();
            }
            else
            {
                dgve_DimensionDetail.AddNewRow();
            }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tsb_Delete_Click(object sender, EventArgs e)
        {
            if (tabControl1.SelectedIndex == 0)
            {
                dgve_Dimension.DeleteRows();
            }
            else
            {
                dgve_DimensionDetail.DeleteRows();
            }
        }

        
    }
}
